Introduction: This R Markdown Document will analysis spatiotemeral data from an AFL Game as part of my asssesment 3 for SES7005.
# The following packages will be used throughout the analysis process.
library(tidyverse)
library(plotly)
library(viridis)
# Let's import Data set 2 will be the focus of this report
RawData <- read.csv("Assessment3_SpatiotemporalDataset2.csv")
# Remove all the NA's form data set. This will allows us to focus on the performance indicators also makes things a bit easier to work with
MatchData <- na.omit(RawData)
# Do a quick summary of the event data which will be used for our first plot
SummaryStats <- MatchData %>%
select(Game, Action, Location, Quarter)
Total Performance Indicators by Game:
# First off, lets get see how this athlete has performed, based on the total of their performance indicators, across a 5 games
Plot1 <- ggplot(data = SummaryStats) +
geom_bar(aes(x = Quarter, fill = Location)) +
theme_classic() +
theme(legend.title = element_blank()) +
theme(axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(legend.position = "bottom") +
labs(y = "Total") +
facet_wrap(~ Game)
ggplotly(Plot1)
Total Performance Indicators by Quarter:
# Here we can see the action areas for the athlete. This plot shows which the athlete accumulated most of their possession based on field location.
Plot2 <- MatchData %>%
count(Location, Quarter) %>%
ggplot(aes(x = Quarter, y = Location)) +
theme_classic() +
theme(axis.title.y = element_blank()) +
geom_tile(aes(fill = n))
ggplotly(Plot2)
Specific Action Data The two plots below show data points for specifc action data (Plot 1 = Handball Data, Plot 2 = Kicking Data)
HANDBALL DATA
#Handball Data
HandballData <- MatchData %>%
filter(Action == "Handball Effective" | Action == "Handball Ineffective" | Action == "Handball Clanger")
HBD <- ggplot(HandballData, aes(x= Quarter, y = Location)) +
geom_jitter(aes(colour = Action), size = 2) +
theme_bw() +
theme(legend.title = element_blank(),
axis.title.y=element_blank()) +
scale_colour_viridis_d()
ggplotly(HBD)
KICKING DATA
# Kicking Data
KickingData <- MatchData %>%
filter(Action == "Kick Backwards" | Action == "Kick Clanger" | Action == "Kick Ineffective" | Action == "Kick Inside 50" | Action == "Kick Short" | Action == "Kick Long")
KickData <- ggplot(KickingData, aes(x= Quarter, y = Location)) +
geom_jitter(aes(colour = Action), size = 2) +
theme_bw() +
theme(legend.title = element_blank(),
axis.title.y=element_blank()) +
scale_colour_viridis_d()
ggplotly(KickData)